package com.cskaoyan.bean.order;

import com.cskaoyan.bean.MarketChannelData;
import com.cskaoyan.bean.MarketOrder;
import com.cskaoyan.bean.MarketOrderGoods;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @ClassName:OrderInfo
 * @Description:TODO
 * @author:leiwenjie
 * @date:2022/9/11 13:12
 * @version:1.0
 */
@Data
public class OrderInfo {

    private BigDecimal actualPrice;

    private Short aftersaleStatus;

    private List<MarketOrderGoods>  goodsList;

    private Integer id;

    private HandleOption handleOption;

    private boolean isGroupin;

    private String orderSn;

    private String orderStatusText;


    private Integer userId;

    private Short orderStatus;

    private String consignee;

    private String mobile;

    private String address;

    private String message;

    private BigDecimal goodsPrice;

    private BigDecimal freightPrice;

    private BigDecimal couponPrice;

    private BigDecimal integralPrice;

    private BigDecimal grouponPrice;

    private BigDecimal orderPrice;

    private String payId;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date payTime;

    private String shipSn;

    private String shipChannel;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date shipTime;

    private BigDecimal refundAmount;

    private String refundType;

    private String refundContent;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date refundTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date confirmTime;

    private Short comments;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date endTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date addTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    private Boolean deleted;

    private String expCode;

    private String expName;

    private String expNo;


    public static OrderInfo detail(MarketOrder marketOrder) {

        OrderInfo orderInfo = new OrderInfo();
        orderInfo.setActualPrice(marketOrder.getActualPrice());
        orderInfo.setAddTime(marketOrder.getAddTime());
        orderInfo.setAddress(marketOrder.getAddress());
        orderInfo.setAftersaleStatus(marketOrder.getAftersaleStatus());
        orderInfo.setConsignee(marketOrder.getConsignee());
        orderInfo.setCouponPrice(marketOrder.getCouponPrice());
        orderInfo.setFreightPrice(marketOrder.getFreightPrice());
        orderInfo.setGoodsPrice(marketOrder.getGoodsPrice());
        orderInfo.setId(marketOrder.getId());
        orderInfo.setMessage(marketOrder.getMessage());
        orderInfo.setMobile(marketOrder.getMobile());
        orderInfo.setOrderSn(marketOrder.getOrderSn());
        orderInfo.setExpNo(marketOrder.getShipSn());
        orderInfo.setExpCode(marketOrder.getShipChannel());
        orderInfo.setExpName(MarketChannelData.getValue(marketOrder.getShipChannel()));
        return orderInfo;
    }

    public static String setStatusText(short status) {
        String statusText = null;
        switch (status) {
            case 101:
                statusText = "未付款";
                break;
            case 102:
                statusText = "用户取消";
                break;
            case 103:
                statusText = "系统取消";
                break;
            case 201:
                statusText = "已付款";
                break;
            case 202:
                statusText = "申请退款";
                break;
            case 203:
                statusText = "已退款";
                break;
            case 301:
                statusText = "已发货";
                break;
            case 401:
                statusText = "用户收货";
                break;
            case 402:
                statusText = "系统收货";
                break;
        }
        return statusText;
    }
}
